﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.BLL;
using Wp.DAL;

public partial class Admin_Modules_Comments_CommentEdit : System.Web.UI.Page
{
    public int Id { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        Id = CommonHelper.QueryStringInt("Id", -1);
        if (Id == -1)
        {
            Response.Redirect("~/Admin/Modules/Comments/Default.aspx");
        }
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    void LoadData()
    {
        TblCommentsEntity item = TblCommentsManager.CreateInstant().SelectOne(Id);
        if (item != null)
        {
            txtContent.Text = item.Content;
            txtUserName.Text = item.Author;
        }
    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        TblCommentsEntity item = TblCommentsManager.CreateInstant().SelectOne(Id);
        item.Content = txtContent.Text;
        item.Author = txtUserName.Text;
        TblCommentsManager.CreateInstant().InsertUpdate(item);
        lblError.Text = "Data was updated successfully";

    }
}